package com.glodon.paas.monitor.server.exception;

/**
 * 所有抛出的异常统一为此异常或此异常的子类，errorCode存放错误码 错误码小于0。<br>
 * 每个模块可以继承此类生成自己的异常类。每个模块设置本模块的错误码取值范围，通用的错误码集中在ErrorCode静态类中描述。<br>
 * 
 * @author licx
 */
public class MonitorException extends RuntimeException {

	private static final long	serialVersionUID	= -8597889575091962218L;

	private Integer				errorCode;

	/**
	 * 通用错误码 -1~-999
	 * 
	 */
	public static final class ErrorCode {

		/*
		 * 参数无效
		 */
		public static final int	PARAM_INVALID	= -10;
		public static final int	UNKNOW_ERROR	= -99;

		/*
		 * 并发更新冲突
		 */
		public static final int	UPDATE_CONFLICT	= -100;

		/*
		 * 操作异常
		 */
		public static final int	SAVE_ERROR		= -101;
	}

	/**
	 * -1000~-1999 应用配置模块错误
	 * 
	 */
	public static final class ApplicationErrorCode {

	}

	public MonitorException(String errorDesc) {
		super(errorDesc);
		this.errorCode = ErrorCode.UNKNOW_ERROR;
	}

	public MonitorException(String errorDesc, Throwable cause) {
		super(errorDesc, cause);
		this.errorCode = ErrorCode.UNKNOW_ERROR;
	}

	public MonitorException(Integer errorCode, String errorDesc) {
		super(errorDesc);
		this.errorCode = errorCode;
	}

	public MonitorException(Integer errorCode, String errorDesc, Throwable cause) {
		super(errorDesc, cause);
		this.errorCode = errorCode;
	}

	public void setErrorCode(Integer errorCode) {
		this.errorCode = errorCode;
	}

	public Integer getErrorCode() {
		return errorCode;
	}

}
